home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / test / test_getargs2.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2005-10-18  |  7KB  |  195 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. import unittest
  5. from test import test_support
  6. import sys
  7. import warnings
  8. import re
  9. warnings.filterwarnings('ignore', category = DeprecationWarning, message = '.*integer argument expected, got float', module = __name__)
  10. warnings.filterwarnings('ignore', category = DeprecationWarning, message = '.*integer argument expected, got float', module = 'unittest')
  11. LARGE = 2147483647
  12. VERY_LARGE = 0xFF0000121212121212121242L
  13. from _testcapi import UCHAR_MAX, USHRT_MAX, UINT_MAX, ULONG_MAX, INT_MAX, INT_MIN, LONG_MIN, LONG_MAX
  14. LLONG_MAX = 2 ** 63 - 1
  15. LLONG_MIN = -2 ** 63
  16. ULLONG_MAX = 2 ** 64 - 1
  17.  
  18. class Long:
  19.     
  20.     def __int__(self):
  21.         return 0x63L
  22.  
  23.  
  24.  
  25. class Int:
  26.     
  27.     def __int__(self):
  28.         return 99
  29.  
  30.  
  31.  
  32. class Unsigned_TestCase(unittest.TestCase):
  33.     
  34.     def test_b(self):
  35.         getargs_b = getargs_b
  36.         import _testcapi
  37.         self.failUnlessEqual(3, getargs_b(3.1400000000000001))
  38.         self.failUnlessEqual(99, getargs_b(Long()))
  39.         self.failUnlessEqual(99, getargs_b(Int()))
  40.         self.assertRaises(OverflowError, getargs_b, -1)
  41.         self.failUnlessEqual(0, getargs_b(0))
  42.         self.failUnlessEqual(UCHAR_MAX, getargs_b(UCHAR_MAX))
  43.         self.assertRaises(OverflowError, getargs_b, UCHAR_MAX + 1)
  44.         self.failUnlessEqual(42, getargs_b(42))
  45.         self.failUnlessEqual(42, getargs_b(0x2AL))
  46.         self.assertRaises(OverflowError, getargs_b, VERY_LARGE)
  47.  
  48.     
  49.     def test_B(self):
  50.         getargs_B = getargs_B
  51.         import _testcapi
  52.         self.failUnlessEqual(3, getargs_B(3.1400000000000001))
  53.         self.failUnlessEqual(99, getargs_B(Long()))
  54.         self.failUnlessEqual(99, getargs_B(Int()))
  55.         self.failUnlessEqual(UCHAR_MAX, getargs_B(-1))
  56.         self.failUnlessEqual(UCHAR_MAX, getargs_B(-0x1L))
  57.         self.failUnlessEqual(0, getargs_B(0))
  58.         self.failUnlessEqual(UCHAR_MAX, getargs_B(UCHAR_MAX))
  59.         self.failUnlessEqual(0, getargs_B(UCHAR_MAX + 1))
  60.         self.failUnlessEqual(42, getargs_B(42))
  61.         self.failUnlessEqual(42, getargs_B(0x2AL))
  62.         self.failUnlessEqual(UCHAR_MAX & VERY_LARGE, getargs_B(VERY_LARGE))
  63.  
  64.     
  65.     def test_H(self):
  66.         getargs_H = getargs_H
  67.         import _testcapi
  68.         self.failUnlessEqual(3, getargs_H(3.1400000000000001))
  69.         self.failUnlessEqual(99, getargs_H(Long()))
  70.         self.failUnlessEqual(99, getargs_H(Int()))
  71.         self.failUnlessEqual(USHRT_MAX, getargs_H(-1))
  72.         self.failUnlessEqual(0, getargs_H(0))
  73.         self.failUnlessEqual(USHRT_MAX, getargs_H(USHRT_MAX))
  74.         self.failUnlessEqual(0, getargs_H(USHRT_MAX + 1))
  75.         self.failUnlessEqual(42, getargs_H(42))
  76.         self.failUnlessEqual(42, getargs_H(0x2AL))
  77.         self.failUnlessEqual(VERY_LARGE & USHRT_MAX, getargs_H(VERY_LARGE))
  78.  
  79.     
  80.     def test_I(self):
  81.         getargs_I = getargs_I
  82.         import _testcapi
  83.         self.failUnlessEqual(3, getargs_I(3.1400000000000001))
  84.         self.failUnlessEqual(99, getargs_I(Long()))
  85.         self.failUnlessEqual(99, getargs_I(Int()))
  86.         self.failUnlessEqual(UINT_MAX, getargs_I(-1))
  87.         self.failUnlessEqual(0, getargs_I(0))
  88.         self.failUnlessEqual(UINT_MAX, getargs_I(UINT_MAX))
  89.         self.failUnlessEqual(0, getargs_I(UINT_MAX + 1))
  90.         self.failUnlessEqual(42, getargs_I(42))
  91.         self.failUnlessEqual(42, getargs_I(0x2AL))
  92.         self.failUnlessEqual(VERY_LARGE & UINT_MAX, getargs_I(VERY_LARGE))
  93.  
  94.     
  95.     def test_k(self):
  96.         getargs_k = getargs_k
  97.         import _testcapi
  98.         self.assertRaises(TypeError, getargs_k, 3.1400000000000001)
  99.         self.assertRaises(TypeError, getargs_k, Long())
  100.         self.assertRaises(TypeError, getargs_k, Int())
  101.         self.failUnlessEqual(ULONG_MAX, getargs_k(-1))
  102.         self.failUnlessEqual(0, getargs_k(0))
  103.         self.failUnlessEqual(ULONG_MAX, getargs_k(ULONG_MAX))
  104.         self.failUnlessEqual(0, getargs_k(ULONG_MAX + 1))
  105.         self.failUnlessEqual(42, getargs_k(42))
  106.         self.failUnlessEqual(42, getargs_k(0x2AL))
  107.         self.failUnlessEqual(VERY_LARGE & ULONG_MAX, getargs_k(VERY_LARGE))
  108.  
  109.  
  110.  
  111. class Signed_TestCase(unittest.TestCase):
  112.     
  113.     def test_i(self):
  114.         getargs_i = getargs_i
  115.         import _testcapi
  116.         self.failUnlessEqual(3, getargs_i(3.1400000000000001))
  117.         self.failUnlessEqual(99, getargs_i(Long()))
  118.         self.failUnlessEqual(99, getargs_i(Int()))
  119.         self.assertRaises(OverflowError, getargs_i, INT_MIN - 1)
  120.         self.failUnlessEqual(INT_MIN, getargs_i(INT_MIN))
  121.         self.failUnlessEqual(INT_MAX, getargs_i(INT_MAX))
  122.         self.assertRaises(OverflowError, getargs_i, INT_MAX + 1)
  123.         self.failUnlessEqual(42, getargs_i(42))
  124.         self.failUnlessEqual(42, getargs_i(0x2AL))
  125.         self.assertRaises(OverflowError, getargs_i, VERY_LARGE)
  126.  
  127.     
  128.     def test_l(self):
  129.         getargs_l = getargs_l
  130.         import _testcapi
  131.         self.failUnlessEqual(3, getargs_l(3.1400000000000001))
  132.         self.failUnlessEqual(99, getargs_l(Long()))
  133.         self.failUnlessEqual(99, getargs_l(Int()))
  134.         self.assertRaises(OverflowError, getargs_l, LONG_MIN - 1)
  135.         self.failUnlessEqual(LONG_MIN, getargs_l(LONG_MIN))
  136.         self.failUnlessEqual(LONG_MAX, getargs_l(LONG_MAX))
  137.         self.assertRaises(OverflowError, getargs_l, LONG_MAX + 1)
  138.         self.failUnlessEqual(42, getargs_l(42))
  139.         self.failUnlessEqual(42, getargs_l(0x2AL))
  140.         self.assertRaises(OverflowError, getargs_l, VERY_LARGE)
  141.  
  142.  
  143.  
  144. class LongLong_TestCase(unittest.TestCase):
  145.     
  146.     def test_L(self):
  147.         getargs_L = getargs_L
  148.         import _testcapi
  149.         self.failUnlessRaises(TypeError, getargs_L, 'Hello')
  150.         self.failUnlessEqual(3, getargs_L(3.1400000000000001))
  151.         self.failUnlessEqual(99, getargs_L(Long()))
  152.         self.failUnlessEqual(99, getargs_L(Int()))
  153.         self.assertRaises(OverflowError, getargs_L, LLONG_MIN - 1)
  154.         self.failUnlessEqual(LLONG_MIN, getargs_L(LLONG_MIN))
  155.         self.failUnlessEqual(LLONG_MAX, getargs_L(LLONG_MAX))
  156.         self.assertRaises(OverflowError, getargs_L, LLONG_MAX + 1)
  157.         self.failUnlessEqual(42, getargs_L(42))
  158.         self.failUnlessEqual(42, getargs_L(0x2AL))
  159.         self.assertRaises(OverflowError, getargs_L, VERY_LARGE)
  160.  
  161.     
  162.     def test_K(self):
  163.         getargs_K = getargs_K
  164.         import _testcapi
  165.         self.assertRaises(TypeError, getargs_K, 3.1400000000000001)
  166.         self.assertRaises(TypeError, getargs_K, Long())
  167.         self.assertRaises(TypeError, getargs_K, Int())
  168.         self.failUnlessEqual(ULLONG_MAX, getargs_K(ULLONG_MAX))
  169.         self.failUnlessEqual(0, getargs_K(0))
  170.         self.failUnlessEqual(0, getargs_K(ULLONG_MAX + 1))
  171.         self.failUnlessEqual(42, getargs_K(42))
  172.         self.failUnlessEqual(42, getargs_K(0x2AL))
  173.         self.failUnlessEqual(VERY_LARGE & ULLONG_MAX, getargs_K(VERY_LARGE))
  174.  
  175.  
  176.  
  177. def test_main():
  178.     tests = [
  179.         Signed_TestCase,
  180.         Unsigned_TestCase]
  181.     
  182.     try:
  183.         getargs_L = getargs_L
  184.         getargs_K = getargs_K
  185.         import _testcapi
  186.     except ImportError:
  187.         pass
  188.  
  189.     tests.append(LongLong_TestCase)
  190.     test_support.run_unittest(*tests)
  191.  
  192. if __name__ == '__main__':
  193.     test_main()
  194.  
  195.